1 <?php
2 session_start(); // Use session variable on this page. This function must put on the top of page.
3 if(!isset($_SESSION['username']) || $_SESSION['usertype'] !='admin'){ // if session variable "username" does not exist.
4 header("location:index.php?msg=Please%20login%20to%20access%20admin%20area%20!"); // Re-direct to index.php
5 }
6 else
7 {
8 include_once "db.php";
9 error_reporting (E_ALL ^ E_NOTICE);
10
11
12 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
13 "http://www.w3.org/TR/html4/loose.dtd">
14 <html>
15 <head>
16 <title>Welcome to Stock Management System !</title>
17 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
18 <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
19 <link rel="stylesheet" href="css/template.css" type="text/css" media="screen" title="no title" charset="utf-8" />
20 <script src="js/jquery.min.js" type="text/javascript"></script>
21
22 <script src="js/jquery.hotkeys-0.7.9.js"></script>
23 <!-- AJAX SUCCESS TEST FONCTION
24 <script>function callSuccessFunction(){alert("success executed")}
25 function callFailFunction(){alert("fail executed")}
26 </script>
27 -->
28
29
30 <script LANGUAGE="JavaScript">
31 <!--
32 // Nannette Thacker http://www.shiningstar.net
33 function confirmSubmit()
34 {
35 var agree=confirm("Are you sure you wish to Delete this Entry?");
36 if (agree)
37 return true ;
38 else
39 return false ;
40 }
41
42 function confirmDeleteSubmit()
43 {
44 var agree=confirm("Are you sure you wish to Delete Seletec Record?");
45 if (agree)
46
47 document.deletefiles.submit();
48 else
49 return false ;
50 }
51
52
53 function checkAll()
54 {
55
56 var field=document.forms.deletefiles;
57 for (i = 0; i < field.length; i++)
58 field[i].checked = true ;
59 }
60
61 function uncheckAll()
62 {
63 var field=document.forms.deletefiles;
64 for (i = 0; i < field.length; i++)
65 field[i].checked = false ;
66 }
67 // -->
68 </script>
69 <script>
70
71
72
73
74
75 $(document).ready(function() {
76 // SUCCESS AJAX CALL, replace "success: false," by: success : function() { callSuccessFunction() },
77 $("#name").focus();
78 $("#form1").validationEngine(),
79
80 jQuery(document).bind('keydown', 'Ctrl+s',function() {
81 $('#form1').submit();
82 return false;
83 });
84
85 jQuery(document).bind('keydown', 'Ctrl+r',function() {
86 $('#form1').reset();
87 return false;
88 });
89 jQuery(document).bind('keydown', 'Ctrl+a',function() {
90 window.location = "addstock.php";
91 return false;
92 });
93 jQuery(document).bind('keydown', 'Ctrl+0',function() {
94 window.location = "admin.php";
95 return false;
96 });
97 jQuery(document).bind('keydown', 'Ctrl+1',function() {
98 window.location = "add_purchase.php";
99 return false;
100 });
101 jQuery(document).bind('keydown', 'Ctrl+2',function() {
102 window.location = "add_stock_sales.php";
103 return false;
104 });
105 jQuery(document).bind('keydown', 'Ctrl+3',function() {
106 window.location = "add_stock_details.php";
107 return false;
108 });
109 jQuery(document).bind('keydown', 'Ctrl+4',function() {
110 window.location = "add_category.php";
111 return false;
112 });
113 jQuery(document).bind('keydown', 'Ctrl+5',function() {
114 window.location = "add_supplier_details.php";
115 return false;
116 });
117 jQuery(document).bind('keydown', 'Ctrl+6',function() {
118 window.location = "add_customer_details.php";
119 return false;
120 });
121 jQuery(document).bind('keydown', 'Ctrl+7',function() {
122 window.location = "view_stock_entries.php";
123 return false;
124 });
125 jQuery(document).bind('keydown', 'Ctrl+8',function() {
126 window.location = "view_stock_sales.php";
127 return false;
128 });
129 jQuery(document).bind('keydown', 'Ctrl+9',function() {
130 window.location = "view_stock_details.php";
131 return false;
132 });
133 //$.validationEngine.loadValidation("#date")
134 //alert($("#formID").validationEngine({returnIsValid:true}))
135 //$.validationEngine.buildPrompt("#date","This is an example","error") // Exterior prompt build example // input prompt close example
136 //$.validationEngine.closePrompt(".formError",true) // CLOSE ALL OPEN PROMPTS
137 });
138 </script>
139 <style type="text/css">
140 <!--
141 body {
142 margin-left: 0px;
143 margin-top: 0px;
144 margin-right: 0px;
145 margin-bottom: 0px;
146 background-color: #FFFFFF;
147 }
148
149 *{
150 padding: 0px;
151 margin: 0px;
152 }
153 #vertmenu {
154 font-family: Verdana, Arial, Helvetica, sans-serif;
155 font-size: 100%;
156 width: 160px;
157 padding: 0px;
158 margin: 0px;
159 }
160
161 #vertmenu h1 {
162 display: block;
163 background-color:#FF9900;
164 font-size: 90%;
165 padding: 3px 0 5px 3px;
166 border: 1px solid #000000;
167 color: #333333;
168 margin: 0px;
169 width:159px;
170 }
171
172 #vertmenu ul {
173 list-style: none;
174 margin: 0px;
175 padding: 0px;
176 border: none;
177 }
178 #vertmenu ul li {
179 margin: 0px;
180 padding: 0px;
181 }
182 #vertmenu ul li a {
183 font-size: 80%;
184 display: block;
185 border-bottom: 1px dashed #C39C4E;
186 padding: 5px 0px 2px 4px;
187 text-decoration: none;
188 color: #666666;
189 width:160px;
190 }
191
192 #vertmenu ul li a:hover, #vertmenu ul li a:focus {
193 color: #000000;
194 background-color: #eeeeee;
195 }
196 .style1 {color: #000000}
197 div.pagination {
198
199 padding: 3px;
200
201 margin: 3px;
202
203 }
204
205
206
207 div.pagination a {
208
209 padding: 2px 5px 2px 5px;
210
211 margin: 2px;
212
213 border: 1px solid #AAAADD;
214
215
216
217 text-decoration: none; /* no underline */
218
219 color: #000099;
220
221 }
222
223 div.pagination a:hover, div.pagination a:active {
224
225 border: 1px solid #000099;
226
227
228
229 color: #000;
230
231 }
232
233 div.pagination span.current {
234
235 padding: 2px 5px 2px 5px;
236
237 margin: 2px;
238
239 border: 1px solid #000099;
240
241
242
243 font-weight: bold;
244
245 background-color: #000099;
246
247 color: #FFF;
248
249 }
250
251 div.pagination span.disabled {
252
253 padding: 2px 5px 2px 5px;
254
255 margin: 2px;
256
257 border: 1px solid #EEE;
258
259
260
261 color: #DDD;
262
263 }
264
265
266 -->
267 </style>
268
269 </head>
270
271 <body>
272 <table width="100%" border="0" cellspacing="0" cellpadding="0">
273 <tr>
274 <td align="center" valign="top"><table width="960" border="0" cellspacing="0" cellpadding="0">
275 <tr>
276 <td><table width="960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
277 <tr>
278 <td height="90" align="left" valign="top"><img src="images/topbanner.jpg" width="960" height="82"></td>
279 </tr>
280 <tr>
281 <td height="800" align="left" valign="top"><table width="960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
282 <tr>
283 <td width="130" align="left" valign="top">
284
285 <br>
286
287 <strong>Welcome <font color="#3399FF"><?php echo $_SESSION['username']; ?> !</font></strong><br> <br>
288 <table width="100%" border="0" cellspacing="0" cellpadding="0">
289 <tr>
290 <td align="center"><a href="admin.php"><img src="images/home.png" width="130" height="99" border="0"></a></td>
291 </tr>
292 <tr>
293 <td align="center"> </td>
294 </tr>
295 <tr>
296 <td align="center"><a href="add_purchase.php"><img src="images/purchase.png" width="130" height="124" border="0"></a></td>
297 </tr>
298 <tr>
299 <td align="center"> </td>
300 </tr>
301 <tr>
302 <td align="center"><a href="add_stock_sales.php"><img src="images/sales.png" width="146" height="111" border="0"></a></td>
303 </tr>
304 <tr>
305 <td align="center"> </td>
306 </tr>
307 <tr>
308 <td align="center"><a href="report.php"><img src="images/reports.png" width="131" height="142" border="0"></a></td>
309 </tr>
310 <tr>
311 <td align="center"> </td>
312 </tr>
313 <tr>
314 <td align="center"> </td>
315 </tr>
316 <tr>
317 <td align="center"> </td>
318 </tr>
319 </table>
320
321
322
323
324
325 </td> <td height="500" align="center" valign="top">
326 <table width="100%" border="0" cellspacing="0" cellpadding="0">
327 <tr>
328 <td><a href="add_stock_details.php"><img src="images/addstockdetails.png" width="67" height="62" border="0"></a></td>
329 <td><a href="add_supplier_details.php"><img src="images/supplier.png" width="67" height="54" border="0"></a></td>
330 <td><a href="add_customer_details.php"><img src="images/customer.png" width="67" height="54" border="0"></a></td>
331 <td><a href="add_category.php"><img src="images/categories.png" width="67" height="54" border="0"></a></td>
332 <td><a href="view_stock_sales.php"><img src="images/vsales.png" width="67" height="54" border="0"></a></td>
333 <td><a href="view_stock_entries.php"><img src="images/vpurchase.png" width="67" height="54" border="0"></a></td>
334 <td><a href="view_stock_details.php"><img src="images/stockdetails.png" width="67" height="54" border="0"></a></td>
335 <td><a href="view_stock_availability.php"><img src="images/savail.png" width="67" height="54" border="0"></a></td>
336 <td align="left" valign="top"><a href="view_customer_details.php"><img src="images/customers.png" width="94" height="22" border="0"></a><br> <a href="view_supplier_details.php"><img src="images/suppliers.png" width="94" height="22" border="0"></a><br>
337 <a href="view_payments.php"><img src="images/payments.png" width="94" height="22" border="0"></a></td>
338 <td align="left" valign="top"><a href="view_stock_sales_payments.php"><img src="images/outstanding.png" width="94" height="22" border="0"></a><br> <a href="view_stock_entries_payments.php"><img src="images/pendings.png" width="94" height="22" border="0"></a><br>
339 <a href="logout.php"><img src="images/logout.png" width="94" height="22" border="0"></a></td>
340 </tr>
341 </table>
342 <table width="700" border="0" cellspacing="0" cellpadding="0">
343 <tr>
344 <td><form action="" method="post" name="search" >
345 <input name="searchtxt" type="text">
346 <input name="Search" type="submit" value="Search">
347 </form></td>
348 <td><form action="" method="get" name="page">
349 Page per Record<input name="limit" type="text" style="margin-left:5px;" value="<?php if(isset($_GET['limit'])) echo $_GET['limit']; else echo "10"; ?>" size="3" maxlength="3">
350 <input name="go" type="submit" value="Go">
351 <input type="button" name="selectall" value="SelectAll" onClick="checkAll()" style="margin-left:5px;"/>
352 <input type="button" name="unselectall" value="DeSelectAll" onClick="uncheckAll()" style="margin-left:5px;" />
353 <input name="dsubmit" type="button" value="Delete Selected" style="margin-left:5px;" onclick="return confirmDeleteSubmit()"/></form></td>
354 </tr>
355 </table>
356
357 <?php
358
359
360
361 $SQL = "SELECT * FROM supplier_details";
362 if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
363 {
364
365 $SQL = "SELECT * FROM supplier_details WHERE supplier_name LIKE '%".$_POST['searchtxt']."%' OR supplier_address LIKE '%".$_POST['searchtxt']."%' OR supplier_contact1 LIKE '%".$_POST['searchtxt']."%' OR supplier_contact2 LIKE '%".$_POST['searchtxt']."%'";
366
367
368 }
369
370 $tbl_name="supplier_details"; //your table name
371
372 // How many adjacent pages should be shown on each side?
373
374 $adjacents = 3;
375
376
377
378 /*
379
380 First get total number of rows in data table.
381
382 If you have a WHERE clause in your query, make sure you mirror it here.
383
384 */
385
386 $query = "SELECT COUNT(*) as num FROM $tbl_name";
387 if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
388 {
389
390 $query = "SELECT COUNT(*) as num FROM supplier_details WHERE supplier_name LIKE '%".$_POST['searchtxt']."%' OR supplier_address LIKE '%".$_POST['searchtxt']."%' OR supplier_contact1 LIKE '%".$_POST['searchtxt']."%' OR supplier_contact2 LIKE '%".$_POST['searchtxt']."%'";
391
392
393 }
394
395
396 $total_pages = mysql_fetch_array(mysql_query($query));
397
398 $total_pages = $total_pages[num];
399
400
401
402 /* Setup vars for query. */
403
404 $targetpage = "view_supplier_details.php"; //your file name (the name of this file)
405
406 $limit = 10; //how many items to show per page
407 if(isset($_GET['limit']))
408 $limit=$_GET['limit'];
409
410
411 $page = $_GET['page'];
412
413 if($page)
414
415 $start = ($page - 1) * $limit; //first item to display on this page
416
417 else
418
419 $start = 0; //if no page var is given, set start to 0
420
421
422
423 /* Get data. */
424
425 $sql = "SELECT * FROM supplier_details LIMIT $start, $limit ";
426 if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
427 {
428
429 $sql= "SELECT * FROM supplier_details WHERE supplier_name LIKE '%".$_POST['searchtxt']."%' OR supplier_address LIKE '%".$_POST['searchtxt']."%' OR supplier_contact1 LIKE '%".$_POST['searchtxt']."%' OR supplier_contact2 LIKE '%".$_POST['searchtxt']."%' LIMIT $start, $limit";
430
431
432 }
433
434
435 $result = mysql_query($sql);
436
437
438
439 /* Setup page vars for display. */
440
441 if ($page == 0) $page = 1; //if no page var is given, default to 1.
442
443 $prev = $page - 1; //previous page is page - 1
444
445 $next = $page + 1; //next page is page + 1
446
447 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
448
449 $lpm1 = $lastpage - 1; //last page minus 1
450
451
452
453 /*
454
455 Now we apply our rules and draw the pagination object.
456
457 We're actually saving the code to a variable in case we want to draw it more than once.
458
459 */
460
461 $pagination = "";
462
463 if($lastpage > 1)
464
465 {
466
467 $pagination .= "<div class=\"pagination\">";
468
469 //previous button
470
471 if ($page > 1)
472
473 $pagination.= "<a href=\"$targetpage?page=$prev&limit=$limit\">« previous</a>";
474
475 else
476
477 $pagination.= "<span class=\"disabled\">« previous</span>";
478
479
480
481 //pages
482
483 if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
484
485 {
486
487 for ($counter = 1; $counter <= $lastpage; $counter++)
488
489 {
490
491 if ($counter == $page)
492
493 $pagination.= "<span class=\"current\">$counter</span>";
494
495 else
496
497 $pagination.= "<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
498
499 }
500
501 }
502
503 elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
504
505 {
506
507 //close to beginning; only hide later pages
508
509 if($page < 1 + ($adjacents * 2))
510
511 {
512
513 for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
514
515 {
516
517 if ($counter == $page)
518
519 $pagination.= "<span class=\"current\">$counter</span>";
520
521 else
522
523 $pagination.= "<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
524
525 }
526
527 $pagination.= "...";
528
529 $pagination.= "<a href=\"$targetpage?page=$lpm1&limit=$limit\">$lpm1</a>";
530
531 $pagination.= "<a href=\"$targetpage?page=$lastpage&limit=$limit\">$lastpage</a>";
532
533 }
534
535 //in middle; hide some front and some back
536
537 elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
538
539 {
540
541 $pagination.= "<a href=\"$targetpage?page=1&limit=$limit\">1</a>";
542
543 $pagination.= "<a href=\"$targetpage?page=2&limit=$limit\">2</a>";
544
545 $pagination.= "...";
546
547 for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
548
549 {
550
551 if ($counter == $page)
552
553 $pagination.= "<span class=\"current\">$counter</span>";
554
555 else
556
557 $pagination.= "<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
558
559 }
560
561 $pagination.= "...";
562
563 $pagination.= "<a href=\"$targetpage?page=$lpm1&limit=$limit\">$lpm1</a>";
564
565 $pagination.= "<a href=\"$targetpage?page=$lastpage&limit=$limit\">$lastpage</a>";
566
567 }
568
569 //close to end; only hide early pages
570
571 else
572
573 {
574
575 $pagination.= "<a href=\"$targetpage?page=1&limit=$limit\">1</a>";
576
577 $pagination.= "<a href=\"$targetpage?page=2&limit=$limit\">2</a>";
578
579 $pagination.= "...";
580
581 for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
582
583 {
584
585 if ($counter == $page)
586
587 $pagination.= "<span class=\"current\">$counter</span>";
588
589 else
590
591 $pagination.= "<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
592
593 }
594
595 }
596
597 }
598
599
600
601 //next button
602
603 if ($page < $counter - 1)
604
605 $pagination.= "<a href=\"$targetpage?page=$next&limit=$limit\">next »</a>";
606
607 else
608
609 $pagination.= "<span class=\"disabled\">next »</span>";
610
611 $pagination.= "</div>\n";
612
613 }
614
615 ?>
616
617 <form name="deletefiles" action="deleteselected.php" method="post">
618 <input name="table" type="hidden" value="supplier_details">
619 <input name="return" type="hidden" value="view_supplier_details.php">
620
621 <table width="700" border="0" cellspacing="0" cellpadding="0">
622
623 <tr>
624
625 <td bgcolor="#0099FF"><div align="center"><strong><span class="style1">View Supplier Details </span></strong></div></td>
626
627 </tr>
628
629 <tr>
630
631 <td> </td>
632
633 </tr>
634
635 <tr>
636
637 <td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
638
639 <tr>
640
641 <td width="100"><strong>Supplier Name </strong></td>
642
643 <td width="100"><strong>Supplier Address</strong></td>
644
645 <td width="100"><strong>Supplier Contact1 </strong></td>
646
647 <td width="100"><strong>Supplier Cotact 2 </strong></td>
648 <td width="100"><strong>View/Edit</strong></td>
649 <td width="100"><strong>Delete</strong></td>
650 <td width="100"><strong>Select</strong></td>
651
652 </tr>
653
654
655
656
657
658 <?php
659
660
661
662 while($row = mysql_fetch_array($result))
663
664 {
665
666
667
668 $mysqldate=$row['date'];
669
670 $phpdate = strtotime( $mysqldate );
671
672 $phpdate = date("d/m/Y",$phpdate);
673
674
675
676 ?>
677
678 <tr>
679
680
681
682 <td width="100"><?php echo $row['supplier_name']; ?></td>
683
684 <td width="100"><?php echo $row['supplier_address']; ?></td>
685
686 <td width="100"><?php echo $row['supplier_contact1']; ?></td>
687
688
689
690 <td width="100"><?php echo $row['supplier_contact2']; ?></td>
691 <td width="100"> <a href="update_supplier_details.php?sid=<?php echo $row['id'];?>"><img src="images/edit-icon.png" border="0" alt="delete"></a></td>
692 <td width="100"><a onclick="return confirmSubmit()" href="delete.php?id=<?php echo $row['id']; ?>&table=supplier_details&return=view_supplier_details.php"><img src="images/delete.png" border="0" alt="delete"></a></td>
693 <td width="100"> <input type="checkbox" value="<?php echo $row['id']; ?>" name="checklist[]" /></td>
694
695 </tr>
696
697
698
699
700
701
702
703
704
705 <?php
706
707
708
709
710
711 }
712
713
714
715
716
717
718
719
720
721
722
723
724
725 ?>
726
727
728
729
730
731
732
733
734
735
736
737 </table></td>
738
739 </tr>
740
741 <tr>
742
743 <td> </td>
744
745 </tr>
746
747 <tr>
748
749 <td align="center"> </td>
750
751 </tr>
752
753 <tr>
754
755 <td align="center"><div style="margin-left:20px;"><?php echo $pagination; ?></div></td>
756
757 </tr>
758
759 <tr>
760
761 <td align="center"> </td>
762
763 </tr>
764
765 <tr>
766
767 <td> </td>
768
769 </tr>
770
771 <tr>
772
773 <td align="center"> </td>
774
775 </tr>
776
777 <tr>
778
779 <td> </td>
780
781 </tr>
782
783 </table>
784
785
786
787 </form>
788
789
790
791 </td>
792
793 </tr>
794
795 </table>
796
797 </td>
798 </tr>
799 </table>
800
801 </td>
802 </tr>
803 <tr>
804 <td height="30" align="center" bgcolor="#72C9F4">
805 <span class="style1"><a href="http://www.pluskb.com">Developed by PlusKB Innovations</a></span></td>
806 </tr>
807 </table></td>
808 </tr>
809 </table></td>
810 </tr>
811 </table>
812
813 </body>
814 </html>
815 <?php
816 }
817 ?>